Skip to content

feat: chat with Meta AI#201826

Open
alpersamur3 wants to merge 1 commit into
wwebjs:mainfrom
alpersamur3:feat/meta-ai-messaging
Open

feat: chat with Meta AI#201826
alpersamur3 wants to merge 1 commit into
wwebjs:mainfrom
alpersamur3:feat/meta-ai-messaging

Conversation

@alpersamur3

Copy link
Copy Markdown

What

Adds client.sendMetaAiMessage(prompt, options?) — send a prompt to Meta AI and receive its reply as a Message (text or media).

Why

The library could already @-mention Meta AI in groups (invokedBotWid), but there was no way to hold a 1:1 conversation with Meta AI and get the answer back. This adds a first-class method for it.

How

  • Meta AI only replies when the outgoing message carries a bot secret, so the method generates messageSecret + botMessageSecret (via WAWebBotMessageSecret.genBotMsgSecretFromMsgSecret) and attaches them.
  • The text reply streams in as a single message edited in place until its final chunk (botEditType reaches last, or full for a one-shot answer). A generated image arrives as a separate message right after, so the method waits for a finished reply plus a short quiet period and returns the media message when one is produced.
  • Returns a Message, so both text and generated images flow through the existing Message API (downloadMedia, etc.). options.timeout (default 60000 ms) caps the wait.

Usage

const reply = await client.sendMetaAiMessage('What is WhatsApp? Answer in one sentence.');
console.log(reply.body);

// "generate an image ..." prompts come back as an image message
if (reply.hasMedia) {
    const media = await reply.downloadMedia();
}

Notes

Meta AI availability is region-gated by WhatsApp; where available this works even when the web UI entry point is hidden.

Tested

Verified against a live session:

  • Text: "2+2?" → "Dört", capital-of-country prompts → "Ankara" / "Paris".
  • Image: "generate an image of a car" → an image message; downloadMedia() returns the JPEG (~255 KB).
  • Multi-sentence answers stream and resolve fully.

@github-actions github-actions Bot added docs Documentation changes api changes API modifications typings Type definitions utility Utility code labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changes API modifications docs Documentation changes typings Type definitions utility Utility code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant